<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增费用支出')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-fCarCost-add">
            <input name="carId" th:value="${carId}" type="hidden">

            <div class="form-group">
                <label class="col-sm-3 control-label">费用类型：</label>
                <div class="col-sm-8">
                    <select id="costType" name="costType" class="form-control m-b" th:with="type=${@dict.getType('f_zhichu_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">费用(元)：</label>
                <div class="col-sm-8">
                    <input name="cost" class="form-control" type="number" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">支出时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="costTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>

            <div id="you" >
                <div class="form-group">
                    <label class="col-sm-3 control-label">加油量(升)：</label>
                    <div class="col-sm-8">
                        <input name="petrol" class="form-control" type="number">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">行驶里程(公里)：</label>
                    <div class="col-sm-8">
                        <input name="kilometers" class="form-control" type="number">
                    </div>
                </div>
            </div>

            <div id="baoxian" style="display: none">
                <div class="form-group">
                    <label class="col-sm-3 control-label">强险生效时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="qiangInsureSatrtTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">强险结束时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="qiangInsureEndTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">保险公司名称：</label>
                    <div class="col-sm-8">
                        <input name="qiangInsureCompany" class="form-control" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">保费金额(元)：</label>
                    <div class="col-sm-8">
                        <input name="qiangCost" class="form-control" type="number">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">商业险生效时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="shangInsureSatrtTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">商业险结束时间：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="shangInsureEndTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">保险公司名称：</label>
                    <div class="col-sm-8">
                        <input name="shangInsureCompany" class="form-control" type="text">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">保费金额(元)：</label>
                    <div class="col-sm-8">
                        <input name="shangCost" class="form-control" type="number">
                    </div>
                </div>
            </div>

            <div id="chuxian" style="display: none">
                <div class="form-group">
                    <label class="col-sm-3 control-label">时间（交强险）：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="chuQiang" class="form-control" placeholder="yyyy-MM-dd" type="text">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">金额（交强险）：</label>
                    <div class="col-sm-8">
                        <input name="chuQiangCost" class="form-control" type="number">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">时间（商业险）：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="chuShang" class="form-control" placeholder="yyyy-MM-dd" type="text">
                            <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">金额（商业险）：</label>
                    <div class="col-sm-8">
                        <input name="chuShangCost" class="form-control" type="number">
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control"></textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "financial/fCarCost"
        $("#form-fCarCost-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-fCarCost-add').serialize());
            }
        }

        $("input[name='costTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='qiangInsureSatrtTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='qiangInsureEndTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='shangInsureSatrtTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='shangInsureEndTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='chuQiang']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='chuShang']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("#costType").change(function () {
            var state = $(this).val()
            $("#you").css("display","none")
            $("#baoxian").css("display","none")
            $("#chuxian").css("display","none")
            if(state==0){
                $("#you").css("display","block")
            }else if(state==6){
                $("#baoxian").css("display","block")
            }else if(state==7){
                $("#chuxian").css("display","block")
            }
        })

    </script>
</body>
</html>